<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8"/>
    <title>资源上传</title>
    <link rel="stylesheet" type="text/css" media="all" href="/layui/css/layui.css"/>
    <script type="text/javascript" src="/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="/css/common.css"/>
    <link rel="stylesheet" type="text/css" media="all" href="/css/CaseManager.css"/>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>上传资源</legend>
    </fieldset>
</head>
<body>
<br/><br/><br/><br/><br/><br/><br/><br/>
<div  class="layui-container">
    <div class="layui-row">
        <div class="layui-col-xs-offset3">
            <form id="upload" action="/download/uploadAllFile" method="post" enctype="multipart/form-data" class="layui-form layui-form-pane">
                <!--上传人-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">上传人</label>
                    <div id="person"></div>

                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label ">标题</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="title" autocomplete="off"  class="layui-input" />
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label ">一级目录:</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <select name="type"  id="type" lay-filter="SelOne">
                            <option value="" >未选择</option>
                            <option value="Article" >微信文章</option>
                            <option value="Video">宣传视频</option>
                            <option value="CourseWare">培训课件</option>
                            <option value="System">公司制度</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label ">二级目录:</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <select name="type2" id="type2" lay-filter="SelTwo">
                        </select>
                    </div>
                </div>
                <!--<div class="layui-form-item">-->
                    <!--<label class="layui-form-label">类型</label>-->
                    <!--<div class="layui-input-inline" style="width: 300px;">-->
                        <!--<datalist id="typeSelect">-->

                        <!--</datalist>-->
                        <!--<input type="text" list="typeSelect" placeholder="" name="type" autocomplete="off" class="layui-input"/>-->
                    <!--</div>-->
                <!--</div>-->

                <div class="layui-form-item">
                    <label class="layui-form-label ">文章链接</label>
                    <div class="layui-input-inline" style="width: 300px;">
                        <input type="text" name="link" autocomplete="off"  class="layui-input" />
                    </div>
                </div>
                <!--<div class="layui-form-item layui-form-text">-->
                    <!--<label class="layui-form-label " style="width: 410px">简介</label>-->
                    <!--<div class="layui-input-inline" style="width: 410px;">-->
                        <!--<textarea name="explain" style="width: 410px;height: 130px"  class="layui-textarea" placeholder="一段介绍"></textarea>-->
                        <!--&lt;!&ndash;<textarea type="textarea" name="explain" autocomplete="off"  class="layui-input" />&ndash;&gt;-->
                    <!--</div>-->
                <!--</div>-->
                <!--上传文件-->
                <div class="layui-form-item">
                    <label class="layui-form-label ">上传文件 </label>
                    <div class="layui-col-xs-offset2">
                        <input class=" myFileUpload" type="file" name="file"/>
                    </div>
                </div>
                <button type="submit" style="width: 410px;height: 50px" class="layui-btn" lay-filter="adds" onclick="shangchuan()">上传</button>

            </form>
        </div>
    </div>
</div>
<br/><br/><br/><br/><br/><br/><br/>
<div class="fly-footer layui-col-xs-offset5" >
    <p><a target="_blank">我打 - 资源上传</a> 2018</p>
</div>
</body>
<script type="text/javascript">
    function shangchuan(){
        layer.msg("正在上传......",{icon:16,time:0})
    }
    layui.use('form', function(){
        var form = layui.form;
        form.on('select(SelOne)',function (data) {
            var tt = data.value;
            $.get("/Request/typeSelect", {}, function (data) {
                    var  Res ;
                    var objectD = JSON.parse(data);
                    $.each(objectD.rows, function (key, value) {
                        if (value.type.indexOf(tt) != -1 ){
                            var result = '<option value="' + value.type + '">' + value.name.substr(5,value.name.length) + '</option>';
                            Res +=result
                        }
                    })
                    $('#type2').empty().append(Res)
                    layui.use('form', function () {
                        var form = layui.form;
                        form.render();
                    });
                }
            )
        })
    });

    $.get(
        "/Request/typeSelect", {

        }, function (data) {
            var objectD = JSON.parse(data);
            $.each (objectD.rows, function (key, value) {
                var result = '<option value="' + value.name + '">' + value.name + '</option>';
                $('#typeSelect').append(result);
            })
            layui.use('form', function(){
                var form = layui.form;
                form.render();
            });
        }
    )
    $(function () {
        var storage = window.localStorage;
        var result ='<div class="layui-input-inline" style="width: 300px;"><input type="text" name="person" value="'+storage.username+'" readonly="readonly" autocomplete="off"  class="layui-input" /></div>';
        $('#person').append(result);
        layui.use('form', function(){
            var form = layui.form;
            form.render();
        });
        var it =JSON.parse(localStorage.getItem("username"))
        if (it == null){
            loadPage("/plateForm/login")
        }
    })
</script>
</html>